import { EventNames } from "../consts/EventNames";
import Points from "../consts/Points";
import EventBus from "../core/EventBus";
import RootAutomatorWrapper from "../core/RootAutomatorWrapper";

export default class TapAction extends bt.Action {
    public static create(...points: number[]): TapAction {
        return new TapAction(typeof points[0] === 'number' ? points : points[0]);
    }

    constructor(private points: number[]) {
        super();
    }

    execute(input: bt.BlackBoard): number {
        let points = this.points;
        if (!points) {
            points = input.content[Points.BT_POINTS];
        }
        RootAutomatorWrapper.click(points);
        return bt.State.success;
    }
}